package com.tools.common.enums;

import lombok.Getter;

/**
 * 请假类型枚举
 */
@Getter
public enum LeaveTypeEnum {

    ANNUAL_LEAVE("年假", "ANNUAL_LEAVE"),
    SICK_LEAVE("病假", "SICK_LEAVE"),
    PERSONAL_LEAVE("事假", "PERSONAL_LEAVE"),
    MARRIAGE_LEAVE("婚假", "MARRIAGE_LEAVE"),
    MATERNITY_LEAVE("产假", "MATERNITY_LEAVE"),
    PATERNITY_LEAVE("陪产假", "PATERNITY_LEAVE"),
    FUNERAL_LEAVE("丧假", "FUNERAL_LEAVE"),
    COMPENSATORY_LEAVE("调休", "COMPENSATORY_LEAVE"),
    OFFICIAL_LEAVE("公假", "OFFICIAL_LEAVE"),
    OTHER("其他", "OTHER");

    private final String name;
    private final String code;

    LeaveTypeEnum(String name, String code) {
        this.name = name;
        this.code = code;
    }

    /**
     * 根据code获取枚举
     */
    public static LeaveTypeEnum getByCode(String code) {
        for (LeaveTypeEnum type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return OTHER;
    }

    /**
     * 检查是否为有效类型
     */
    public static boolean isValid(String code) {
        for (LeaveTypeEnum type : values()) {
            if (type.getCode().equals(code)) {
                return true;
            }
        }
        return false;
    }

}
